home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Internet / WWW / analog / Source / analhea2.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-07  |  5.4 KB  |  187 lines

  1. /*** analhea2.h; header file for analog version 1.9beta2 ***/
  2. /* Please read Readme.html, or http://www.statslab.cam.ac.uk/~sret1/analog/ */
  3.  
  4. /*** These things are not intended to be user definable; user definable headers
  5.      are in analhead.h ***/
  6.  
  7. #ifndef ANALHEAD2
  8. #define ANALHEAD2
  9.  
  10. /*** First some #define's and #include's ***/
  11.  
  12. #define VERSION "1.9beta2"    /* the version number of this program */
  13.  
  14. #include <stdio.h>
  15. #include <stdlib.h>
  16. #include <math.h>
  17. #include <string.h>
  18. #include <sys/types.h>
  19. #include <sys/time.h>
  20. #include <ctype.h>
  21.  
  22. #ifdef TRUE  /* I suppose everyone else defines TRUE = 1, but I won't */
  23. #undef TRUE  /* risk it by doing an #ifndef! */
  24. #endif
  25. #define TRUE (1)
  26. #ifdef FALSE
  27. #undef FALSE
  28. #endif
  29. #define FALSE (0)
  30. #ifdef ON
  31. #undef ON
  32. #endif
  33. #define ON (TRUE)
  34. #ifdef OFF
  35. #undef OFF
  36. #endif
  37. #define OFF (FALSE)
  38. #ifdef OK
  39. #undef OK
  40. #endif
  41. #define OK (0)
  42. #ifdef ERR
  43. #undef ERR
  44. #endif
  45. #define ERR (-1)
  46. #ifdef UNSET
  47. #undef UNSET
  48. #endif
  49. #define UNSET (-1)
  50. #define BYREQUESTS (0)       /* ways of sorting */
  51. #define BYBYTES (1)
  52. #define ALPHABETICAL (2)
  53. #define RANDOMLY (3)
  54. #define APPROX (2)       /* for hostname counting */
  55. #define ALL (2)          /* see PAGELINKS and REQTYPE in analhead.h */
  56. #define PAGES (1)
  57. #define COMMON (2)       /* three types of input lines */
  58. #define NCSAOLD (1)
  59. #define CORRUPT (0)
  60. #define CACHE (2)        /* output types */
  61. #define ASCII (1)
  62. #define HTML (0)
  63. #ifdef MAX
  64. #undef MAX
  65. #endif
  66. #define MAX(a,b) (((a)>(b))?(a):(b))
  67. #ifdef MIN
  68. #undef MIN
  69. #endif
  70. #define MIN(a,b) (((a)<(b))?(a):(b))
  71. #ifdef ROUND
  72. #undef ROUND
  73. #endif            /* round double to nearest integer (as double) */
  74. #define ROUND(x) (((x)-(floor(x)))>=0.5?ceil(x):floor(x))
  75. #define STREQ(a,b) (strcmp(a,b)==0)
  76. #ifdef INFINITY
  77. #undef INFINITY
  78. #endif            /* something very big (but that will fit in a long) */
  79. #define INFINITY (2000000000)
  80. #define SUNDAY (0)
  81. #define MONDAY (1)
  82. #define TUESDAY (2)
  83. #define WEDNESDAY (3)
  84. #define THURSDAY (4)
  85. #define FRIDAY (5)
  86. #define SATURDAY (6)
  87. #define ISLEAPFEB(m,y) (((m)==1)&&(((y)%4)==0))  /* Feb in leap year */
  88. #define ISLEAPJF(m,y) (((m)<=1)&&(((y)%4)==0))  /* Jan or Feb in leap year */
  89. /* NB Every 4th year from 1901 to 2099 is a leap year */
  90.  
  91. #define DOMHASHSIZE (1354)
  92. /* = 2 * 26^2 + 2 by description of domain algorithm */
  93. #define NO_ERRS (29)   /* how many error types there are (in init.c) */
  94. #define MAXERRLENGTH (40)  /* the longest one */
  95. #define NO_STATUS (22) /* how many status codes are defined */
  96. #define MAXSTATUSLENGTH (35)
  97.  
  98. /*** Now include the user-definable header things ***/
  99.  
  100. #include "analhead.h"
  101.  
  102. /*** Next some global structures ***/
  103.  
  104. typedef int flag;
  105.  
  106. struct timestruct {        /* some things we might want to know about a
  107.                   particular time */
  108.   int date;                /* the day of the month */
  109.   int monthno;             /* 0 for Jan, ... , 11 for Dec */
  110.   int year;                /* 4 digits */
  111.   int hr;                  /* 0 to 23 */
  112.   int min;                 /* 0 to 59 */
  113.   long code;               /* an increasing (though not necessarily linear)
  114.                   function of time, for quick comparisons.
  115.                   Defined in timecode() */
  116. };
  117.  
  118. struct monthly {           /* a structure for a year's worth of monthly data */
  119.   int reqs[12];            /* the number of requests on each month */
  120.   double bytes[12];        /* and bytes ditto */
  121.   struct monthly *next;    /* where the next year's data is */
  122. };
  123.  
  124. struct daily {             /* similarly, for a month's worth of daily data */
  125.   int reqs[31];            /* NB Day n is stored in location (n - 1) */
  126.   double bytes[31];
  127.   struct daily *next;
  128. };
  129.  
  130. struct hourly {            /* and for a day's worth of hourly data */
  131.   int reqs[24];
  132.   double bytes[24];
  133.   struct hourly *next;
  134. };
  135.  
  136. struct weekly {             /* a structure for weekly data */
  137.   int reqs;
  138.   double bytes;
  139.   struct timestruct start;  /* the start of the week */
  140.   struct weekly *next;
  141. };
  142.  
  143. struct genstruct {           /* relevant information about an object */
  144.   char *name;                /* its name */
  145.   int reqs;                  /* its number of requests */
  146.   double bytes;              /* the number of bytes transferred due to it */
  147.   flag pre7;                 /* has been used before last 7 days (host only) */
  148.   flag last7;                /* has been used in the last 7 days? */
  149.   flag aliasdone;            /* have we done an alias on it? (URLs only) */
  150.   struct genstruct *next;    /* the next object in the list */
  151. };
  152.  
  153. struct domain {              /* and domains */
  154.   char *id;                  /* can be as long as host for subdomains */
  155.   char *revid;               /* same reversed */
  156.   char *name;                /* the geographical location of the domain */
  157.   int reqs;
  158.   double bytes;
  159.   int nexti;                 /* the index of the next domain alphabetically */
  160.   struct domain *next;       /* the next subdomain of the current domain */
  161. };
  162.  
  163. struct alias {      /* aliases from the configuration file */
  164.   char from[MAXSTRINGLENGTH];
  165.   char to[MAXSTRINGLENGTH];
  166.   struct alias *next;
  167. };
  168.  
  169. struct include {   /* a list of included/excluded things */
  170.   char name[MAXSTRINGLENGTH];
  171.   int in;           /* TRUE, FALSE or UNSET */
  172.   struct include *next;
  173. };
  174.  
  175. struct loglist {   /* a list of logfiles */
  176.   char name[MAXSTRINGLENGTH];
  177.   char prefix[MAXSTRINGLENGTH];
  178.   struct loglist *next;
  179. };
  180.  
  181. struct stringlist {   /* a simple list of strings */
  182.   char name[MAXSTRINGLENGTH];
  183.   struct stringlist *next;
  184. };
  185.  
  186. #endif  /* not previously included */
  187.